package com.ys.controller;


import com.ys.pojo.Cgoder;
import com.ys.pojo.Drugss;
import com.ys.service.CgoderService;
import com.ys.service.DrugssService;
import com.ys.vo.LocalDataVo;
import com.ys.vo.ResultVo;
import com.ys.vo.TuiVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/access")
public class ZInventoryAccessController {

    @Resource
    private CgoderService cgoderService;        //订单service

    @Resource
    private DrugssService drugssService;        //订单药品

    @GetMapping("/searchAll")
    public ResultVo searchAll(){
        List<Cgoder> list = cgoderService.searchSupId();
        return ResultVo.success(list);
    }

    @PostMapping("/searchOrderId")
    public ResultVo searchOrderId(Integer orderId){
        List<Drugss> list = drugssService.searchOrderId(orderId);
        System.out.println(list);
        return ResultVo.success(list);
    }

    @PostMapping(value = "/updDrugsNumber", produces = "application/json;charset=utf-8")
    public ResultVo updDrugsNumber(@RequestBody Drugss[] orderData,Integer receId){
        boolean isResult = drugssService.Warehousing(orderData,receId);
        if (!isResult){
            ResultVo.failure("入库失败...");
        }
        return ResultVo.success("入库成功!!");
    }
    @PostMapping("/searchDate")
    public ResultVo searchDate(@RequestBody LocalDataVo localData){
        List<Cgoder> list = cgoderService.searchDate(localData.getJinDate());
        return ResultVo.success(list);
    }

    @GetMapping("/searchTui")
    public ResultVo searchTui(){
        List<Cgoder> list = cgoderService.searchTui();
        return ResultVo.success(list);
    }

    @PostMapping("/searchChuTime")
    public ResultVo searchChuTime(@RequestBody TuiVo chuTime){
        System.out.println(chuTime);
        List<Cgoder> list = cgoderService.searchTuiTime(chuTime);
        return ResultVo.success(list);
    }

    @GetMapping("/searchState")
    public ResultVo searchState(String supId){
        List<Cgoder> list = cgoderService.searchState(supId);
        return ResultVo.success(list);
    }

}
